package Native
{
	import Objects.GameBitmap;
	import Objects.GameObject;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	public class NativeBitmap extends Bitmap implements INativeObject
	{
		public function NativeBitmap()
		{
			super();
		}
		private var m_go:GameObject;
		public function set go(value:GameObject):void
		{
			m_go=value;
		}
		public function get go():GameObject
		{
			return m_go;
		}
		public function hitTestAlpha(x:Number, y:Number):Boolean
		{
			var coord:Point=globalToLocal(new Point(x,y));
			var color:uint = bitmapData.getPixel32(coord.x, coord.y);
			var alpha:int= color >> 24 & 0xFF;
			if(alpha > 20)
			{
				return false;
			}
			return true;
		}
		override public function hitTestPoint(x:Number, y:Number, shapeFlag:Boolean=false):Boolean
		{
			var hit:Boolean=super.hitTestPoint(x,y,shapeFlag);
			if(hit&&shapeFlag)
			{
				if(hitTestAlpha(x,y))
				{
					hit=false;
				}
			}
			return hit;
		}
		public function get bitmap():GameBitmap
		{
			return go as GameBitmap;
		}
	}
}